package com.trkj.controller.lzs;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojo.ProjectTemplate;
import com.trkj.pojo.Salary;
import com.trkj.pojo.SalaryAccount;
import com.trkj.pojo.SocialSecurity;
import com.trkj.service.lzs.PayrollService;
import com.trkj.vo.PayrollVo;
import com.trkj.vo.Result;
import com.trkj.vo.Result2;
import com.trkj.vo.payVO;

@Controller
public class PayrollController {
	@Autowired
	private PayrollService payrollservice;
	//查询

	@RequestMapping("lzs_findAllPayroll")
	@ResponseBody
	public List<Salary> getJSON2(){
		List<Salary> list = payrollservice.PayrollAccount();
		list.forEach(e->{
			System.err.println("aaaaa"+e);
		});
		return list;
	}
	 //添加
	@RequestMapping("lzs_Payrolltianjia")
	@ResponseBody
	public void tianjia(String salaryName ,String salsryBeizhu,String salsrySpz,Timestamp salsryPzdate,Timestamp salsryShdate,BigDecimal salaryNumberEmployees){
		payrollservice.tj( salaryName ,salsryBeizhu, salsrySpz, salsryPzdate,salsryShdate ,salaryNumberEmployees );
		System.err.println(salaryName+"a");
		
	}
	//模糊查询shuoy
		@RequestMapping("lzs_payrollchaxun")
		@ResponseBody
		public  List<Salary> Query(String text){
			System.out.println(text);
			return (List<Salary>) payrollservice.queryByName(text);
		}
		/*修改
		*/
		@RequestMapping("lzs_payrollxiugai")
		@ResponseBody  
		public  Result2  payrollxiugaixiugai(long salaryId ,BigDecimal salsryState,BigDecimal salaryNumberEmployees,
				BigDecimal salsrySum, String salsryPerson,String salaryName ,String salsryBeizhu,String salsrySpz,Timestamp salsryPzdate,Timestamp salsryShdate) {
			try {
				payrollservice.lzs_Edit(salaryId, salsryState, salaryNumberEmployees, salsrySum, salsryPerson, salaryName, salsryBeizhu, salsrySpz, salsryPzdate, salsryShdate);
				return Result2.SUCCESS;
			} catch (Exception e) {
					e.printStackTrace();
				return Result2.failure(e.getMessage());
			}
			
		}
		
		@RequestMapping("lzs_payrollxiugai1")
		@ResponseBody  
		 public Salary chunq(Long salaryId) {
	    	 return payrollservice.chun1(salaryId);
	     }
		//删除；通过id查出相应的一条数据
		@RequestMapping("hr_ra_form_payrol")
		@ResponseBody
		public boolean hr_ra_form_payrol(Long salaryId){
			 return payrollservice.dltRe(salaryId);
		}
		//多表查询
		@RequestMapping("lzs_findAllduoSalaryo")
		@ResponseBody
		public List<PayrollVo> duobiao(){
	  
			
			return 	 payrollservice.selcet_Salary();
		}
		/**
		 * 增
		 * @return
		 */
		@PostMapping("lzs_findAllduozjsocialpayroll")
		@ResponseBody
		public Result add_SocialSecurity(Salary Social,Long accountId ){
			try {
				payrollservice.add_Payr(Social,accountId);
				return Result.SUCCESS;
			} catch (Exception e) {
				e.printStackTrace();
				return Result.failure(e.getMessage());
			}
		}
}
